package com.tct.worktimeboard.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tct.worktimeboard.entity.User;
import com.tct.worktimeboard.entity.Work;
import com.tct.worktimeboard.service.CreateGroupService;
import com.tct.worktimeboard.service.IWorkService;
import com.tct.worktimeboard.service.IProjectService;
import com.tct.worktimeboard.service.OAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Huhailong
 * @Description
 * @Date 2021/2/22.
 */
@RestController
@RequestMapping("/test")
public class TestController {
    @Autowired
    private IProjectService IProjectService;
    @Autowired
    private IWorkService workService;
    @Autowired
    private OAService oaService;
    @Autowired
    private CreateGroupService createGroupService;

    @GetMapping("getProject")
    public JSONObject getProject(){
        return IProjectService.getProject();
    }

    @GetMapping("getUser")
    public List<User> getUser(){
        return IProjectService.getUser();
    }

    @GetMapping("getWork")
    public JSONObject getWork(Work work){
        return workService.getWork(work);
    }

    @GetMapping("/getOaUser")
    public JSONArray getOaUser(){
        return oaService.getOaUser();
    }

    @GetMapping("/importOaUser")
    public JSONObject importOaUser(){
        return oaService.importOaUser();
    }

    @GetMapping("/importOaDept")
    public JSONObject importOaDept(){
        return oaService.importOaDept();
    }

    @GetMapping("/autoRegister")
    public JSONObject autoRegister(String registerUrl){
        return oaService.registerBatch(registerUrl);
    }

    @GetMapping("/refreshDept")
    public JSONObject refreshDept(){
        return oaService.refreshDept();
    }

    @GetMapping("/powerUser")
    public JSONObject powerUser(){
        return createGroupService.addPower();
    }

}
